//
//  AppDelegate.swift
//  WeiBoApp
//
//  Created by CrazyHacker on 16/6/29.
//  Copyright © 2016年 CrazyHacker. All rights reserved.
//

import UIKit
import UserNotifications
import SVProgressHUD
import AFNetworking

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        addtionSettings()
        
        window = UIWindow()
        window?.rootViewController = WBMainViewController()
        window?.backgroundColor = #colorLiteral(red: 1, green: 0.99997437, blue: 0.9999912977, alpha: 1)
        window?.makeKeyAndVisible()
        return true
    }

}

// MARK: - 额外设置
extension AppDelegate {
    private func addtionSettings() {
        // 设置最小展示解除时间
        SVProgressHUD.setMinimumDismissTimeInterval(1.0)
        
        // 设置爱网络加载指示器
        AFNetworkActivityIndicatorManager.shared().isEnabled = true
        // 新消息提示,提示用户是否推送
        // 10.0推出此方法
        if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().requestAuthorization([.alert, .sound,.carPlay, .badge]) { (true, error) in
                
            }
        } else {
            // 取得用户授权,(提示条, 声音, BadgeNumber)--将要废弃的设置
            let notifications = UIUserNotificationSettings(types: [.sound, .alert, .badge], categories: nil)
            UIApplication.shared().registerUserNotificationSettings(notifications)
            
        }
    }
}
